#ifndef IMNETWORKPROCESSOR_H
#define IMNETWORKPROCESSOR_H

#include "utility/Def.h"
#include <string>

class IMNetworkProcessor;
class IMNetworkProcessorPrivate;
class IMNetworkProcessorHandlerPrivate;

class IMNetworkProcessorHandler
{
    IM_CREATE_SINGLETON(IMNetworkProcessorHandler)
    IM_CREATE_PRIVATE(IMNetworkProcessorHandler)
public:
    void setNext(const std::string &name);
    void setNext(std::shared_ptr<IMNetworkProcessor> next);
    void run(const unsigned char *data, int length);
};

class IMNetworkProcessor
{
    IM_CREATE_PRIVATE(IMNetworkProcessor)
public:
    virtual ~IMNetworkProcessor() = default;
    void next(std::shared_ptr<IMNetworkProcessor> next);
    std::shared_ptr<IMNetworkProcessor> next() const;
    virtual void setName(const std::string &name);
    virtual std::string name() const;
    virtual void process(const unsigned char *data, int length) = 0;
};

#endif